package cn.kgc.config;

import cn.kgc.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AppConfig implements WebMvcConfigurer {

    //配置请求url地址与视图页面的映射关系
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/manage/tologin").setViewName("pages/devlogin");
        registry.addViewController("/manage/main").setViewName("pages/developer/main");
    }

    //配置拦截器组件
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/manage/**")
                .excludePathPatterns("/manage/devuser","/manage/tologin");
    }
}
